package com.hevs.samplewebapp.server.dao;

import java.util.List;

import com.google.appengine.api.datastore.Key;
import com.hevs.samplewebapp.server.entities.User;

/**
 * Interface for the Data "user", to update, remove and get all the medical data.
 * 
 * @author Arnaud Durand
 * @date 12.03.12
 */

public interface UserDAO {

	/**
	 * Methode to get all the users
	 * @return
	 * a list of user
	 */
	public abstract List<User> getAll();
	
	/**
	 * Method to retrieve a user by its Key
	 * @param key
	 * key of the user
	 * @return
	 * a user
	 */
	public abstract User getUser(Key key);
	
	/**
	 * Method to retrieve a user by its Login
	 * @param login
	 * login of the user
	 * @return
	 * a user
	 */
	public abstract User getUserByLogin(String login);
	
	/**
	 * Method to retrieve a user by Email
	 * @param mail
	 * email of the user
	 * @return
	 * a user
	 */
	public abstract User getUserByMail(String mail);

	// Update a user
	/**
	 * Method to update a user's informations
	 * @param user
	 * the user to update
	 */
	public abstract void update(User user);

	// Remove a user
	/**
	 * Method to delete a user
	 * @param user
	 * the user to delete 
	 */
	public abstract void remove(User user);
	
	/**
	 * Method to retrieve the List of user granted by the user
	 * @param local
	 * the user who granted the other
	 * @return
	 * a list of users
	 */
	public abstract List<User> getGrantedUsers(User local);
	
	/**
	 * Method to grant a user to see medical data
	 * @param local
	 * the owner of the medical data
	 * @param remote
	 * the granted user
	 */
	public abstract void grantAccess(User local, User remote);
	
	/**
	 * Method to revoke a user to see medical data
	 * @param local
	 * the owner of the medical data
	 * @param remote
	 * the revoked user
	 */
	public abstract void revokeAccess(User local, User remote);
	
}
